<template>
	<div class="uiue-card" style="padding-top: 0" v-if="configKey">
		<a-tabs v-model:activeKey="configKey" class="tabss" @change="configHandleChange">
			<a-tab-pane v-for="v in configData" :key="v.key" :tab="v.txt"></a-tab-pane>
		</a-tabs>
		<div class="tit" style="margin: 10px 0">配置信息</div>
		<PcConfig v-if="configKey == '1'" />
		<AppConfig v-if="configKey == '2'" />
	</div>
	<template v-if="configKey === '2'">
		<!-- 0灰名单   1黑名单   2白名单 -->
		<!-- 灰度名单 -->
		<!-- <GrayscaleTable v-if="configKey == '1' && tableName?.includes('PC')" :configKey="configKey" :isblack="'0'" /> -->
		<GrayscaleTableLo :configKey="configKey" :isblack="'0'" />
		<!-- 黑名单 -->
		<GrayscaleTableLo :configKey="configKey" :isblack="'1'" />
		<!-- 白名单 -->
		<GrayscaleTableLo v-if="showWhite" :configKey="configKey" :isblack="'2'" />
	</template>

</template>

<script setup name="Configure">
import tool from '@/utils/tool'
import sysConfig from '@/config/index'
import { useRoute } from 'vue-router'
import AuthImg from '@/components/authImg/index.vue'
import GrayscaleTableLo from '@/components/grayscaleTable/indexLo.vue'
import PcConfig from './pcConfig.vue'
import AppConfig from './appConfig.vue'
const route = useRoute()
const { tableName, isTest } = route.query
const props = defineProps({
	showTable: Boolean,
	appAccess: Array
})

const datas = inject('detailDate')

const currentName = inject('currentName')


const fileUrl = import.meta.env.VITE_FILE_URL_W


// 控制黑名单
const showBlack = computed(() => {
	let bool = false
	if (currentName?.value === '应用上线确认') {
		bool = true
	}
	return bool
})
watch(
	currentName,
	(newData, oldData) => {
		if (newData === '运营组审核' && tableName && tableName.includes('APP')) {
			const { param = '' } = datas.value.appPropertiesList[0]
			tool.session.set('param', param)
		}
	},
	{ immediate: true }
)


const config = sysConfig.DEVICE_CONFIG
// 控制白名单显示
const showWhite = computed(() => {
	let bool = false
	// 如果是审批详情
	if (datas.value.appInfoAppPropertiesAddParam?.permission === '1' && !datas.value.appAccess.includes('1')) {
		bool = true
	}
	return bool
})
const configData = computed(() => {
	let arr = []
	if (datas.value?.appInfoPcPropertiesAddParam && datas.value?.appInfoPcPropertiesAddParam?.accesssBefore == 2) {
		arr.push({ "txt": "门户端", "key": "1", "type": "pcPropertiesList", "oid": "PC" })
	}
	if (datas.value?.appInfoAppPropertiesAddParam && datas.value?.appInfoAppPropertiesAddParam?.accesssBefore == 2) {
		arr.push({ "txt": "移动端Html", "key": "2", "type": "appPropertiesList", "oid": "APP" })
	}
	return arr
})
const configKey = ref()
if (configData.value.length > 0) {
	configKey.value = configData.value[0].key
}
const configHandleChange = (i) => {
	configKey.value = i
}


</script>

<style lang="less" scoped></style>
